﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace EPanShareSystem.Model
{
    /// <summary>
    /// 用户登录上下文
    /// </summary>
    public class LoginContenxt
    {
        /// <summary>
        /// 用户登录信息
        /// </summary>
        /// <param name="userInfo"></param>
        public static void SetUserInfo(Sys_User userInfo)
        {
            if (HttpContext.Current.Session["CurrentUserInfo"] == null)
            {
                HttpContext.Current.Session["CurrentUserInfo"] = userInfo;
            }
        }

        /// <summary>
        /// 清除用户登录信息
        /// </summary>
        public static void ClearUserInfo()
        {
            if (HttpContext.Current.Session["CurrentUserInfo"]!=null)
            {
                HttpContext.Current.Session["CurrentUserInfo"] = null;
            }
        }

        /// <summary>
        /// 返回当前登录的用户
        /// </summary>
        public static Sys_User CurrentUserInfo()
        {
            if (HttpContext.Current.Session["CurrentUserInfo"] != null)
            {
                return HttpContext.Current.Session["CurrentUserInfo"] as Sys_User;
            }
            return null;
        }
    }
}
